﻿using Guoc.BigMall.Application;
using Guoc.BigMall.Application.DTO;
using Guoc.BigMall.Application.Search;
using Guoc.BigMall.Application.ViewObject;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Guoc.BigMall.Admin.Controllers
{
    public class DistributeOrderController : Controller
    {
        IContextFacade _context;
        IDistributeOrderFacade _DistributeOrderFacade;
        public DistributeOrderController(IContextFacade context, IRoleFacade roleFacade, IDistributeOrderFacade DistributeOrderFacade)
        {
            this._context = context;
            this._DistributeOrderFacade = DistributeOrderFacade;
        }
        public ActionResult Index()
        {
            return View();
        }

        public JsonResult LoadData(Pager page, SearchDistributeOrder search)
        {
            var rows = _DistributeOrderFacade.GetList(page, search);
            return Json(new { success = true, data = rows, total = page.Total, JsonRequestBehavior.AllowGet });
        }

        public ActionResult Detail(int id)
        {
            var model = _DistributeOrderFacade.GetDetail(id);
            ViewBag.Order = JsonConvert.SerializeObject(model);
            return View();
        }

        /// <summary>
        /// 查询商品明细
        /// </summary>
        /// <param name="id">商品id productId</param>
        /// <returns></returns>
        public JsonResult GetDetail(int id)
        {
            var model = _DistributeOrderFacade.GetDetail(id);
            return Json(new { success = true, data = model });
        }

        public JsonResult AuditPhone(DistributeOrderAuditDto auditDto)
        {
            _DistributeOrderFacade.AuditPhone(auditDto);
              return Json(new { success = true });
        }
        public JsonResult ConfirmCash(DistributeOrderAuditDto auditDto)
        {
            _DistributeOrderFacade.ConfirmCash(auditDto);
            return Json(new { success = true });
        }

        public JsonResult PaidByFinance(int id)
        {
            _DistributeOrderFacade.PaidByFinance(id);
            return Json(new { success = true });
        }
    }
}